{% extends "homepage.html" %}
{% block content %}

<script src="{{ url_for('static', filename='jquery.column.min.js')}}" type="text/javascript" charset="utf-8"></script>
 <script src="{{ url_for('mwf.static', filename='maass_scripts.js')}}" type="text/javascript" charset="utf-8"></script>
 <script type="text/javascript" charset="utf-8">
 $(document).ready(function() {
jQuery('table:has(col)').each(alignColumns);
var evTable = $("table#eigenvalues").dataTable(
{
   "bPaginate":true,
   "bLengthChange":true,
   "bFilter": true,
   "bInfo": true,
   "bProcessing":true,
   "aoColumns":[{"aaSorting":"asc","sWidth": "10%", "bSortable": true, "bSearchable": true ,"sType":"numeric" },
                 {"sWidth": "5%", "bSortable": true,  "bSearchable": true, "sClass": "alignLeft","fnRender":"text-align:left"},
                 {"sWidth": "5%", "bSortable": false, "bSearchable": true, "sClass": "alignLeft","fnRender":"text-align:left"},
                 {"sWidth": "20%", "bSortable": true,  "bSearchable": true, "sClass": "alignLeft","fnRender":"text-align:left","sType":"numeric"},
                 {"sWidth": "10%", "bSortable": false, "bSearchable": false,"sClass": "alignLeft","fnRender":"text-align:left"},
                 {"sWidth": "10%", "bSortable": false, "bSearchable": false,"sClass": "alignLeft","fnRender":"text-align:left","sType":"numeric"},
                 {"sWidth": "5%", "bSortable": false, "bSearchable": false,"sClass": "alignLeft","fnRender":"text-align:left"},
                 {"sWidth": "5%", "bSortable": false, "bSearchable": false,"sClass": "alignLeft","fnRender":"text-align:left"},
                 {"sWidth": "10%", "bSortable": false, "bSearchable": false,"sClass": "alignLeft","fnRender":"text-align:right","sType":"numeric"},
                 {"sWidth": "20%", "bSortable": false, "bSearchable":
 false,"sClass": "alignLeft", "fnRender":"text-align:left","minWidth":"200px"}],  
    "bSort":true,
    "iDisplayLength": 15,    
    "iDisplayStart": 0,
    "fnSort":[[1,"asc"],[2,"asc"],[3,"asc"]],
    "oLanguage": {
            "sZeroRecords": "There are no eigenvalues that match your search criterion in the current database",
            "sLengthMenu": "Display _MENU_ eigenvalues per page",
            "sInfo": "Displaying _START_ to _END_ of _TOTAL_ eigenvalues",
            "sInfoEmpty": "Showing 0 to 0 of 0 records",
            "sInfoFiltered": "(filtered from _MAX_ total eigenvalues)",
            "sSearch":"Filter records:",
            "oPaginate": {
                        "sPrevious": "Previous",
                        "sNext": "Next"
                }
     }, 
     "bjQueryUI":true,
     "sPaginationType": "full_numbers",
     "sDom": 'ti<"paging"p><"bottom"lfr><"filterbox"><>',
     "sScorollX": "500px", 
     "bStateSave": false,
     "aLengthMenu": [[15, 25, 50, 100 ,200, -1], [15, 25, 50, 100, 200, "All"]],
     "bAutoWidth": false,
     "oSearch": { "sSearch": "", "bRegex": false, "bSmart": true },
 });

/* Add filtering box if we don't have a fixed weight*/

{% if wtis1 !='' %}
s='<input type="hidden" id="weight" value="1">'
$('#eigenvalues_filter').append(s);
{% elif wtis0 !='' %}
s='<input type="hidden" id="weight" value="0">'
$('#eigenvalues_filter').append(s);
{% else %}
s='<br>Weight:<select id="weight"><option selected>0<option>1<option >all </select>'
$('#eigenvalues_filter').append(s);
/* Add event listener to the weight filtering */
$('#weight').change( function() { evTable.fnDraw(); } );
{% endif %}
evTable.fnDraw(); 
$('#eigenvalues_length').css("width","50%")
$('#eigenvalues').css("width","875px")
$('#eigenvalues_wrapper').css("width","875px")
$('#eigenvalues_paginate').css("width","75%")
$('#eigenvalues_paginate').css("text-align","left")
$('.paging_full_numbers').css('width','400px')
$('#eigenvalues_first').css('padding','10px')
$('#eigenvalues_last').css('padding','10px')
$('#eigenvalues_next').css('padding','10px')
$('#eigenvalues_previous').css('padding','10px')

s='<div id="newsearch" class="newsearch"></div>';
$('#content').append(s);
/* $('#content').append($("knowl"));*/
s='<h2>New Search</h2>';
$('#newsearch').append(s);;
s='<form name="search" method = "post" action="{{url_for('.render_maass_waveforms')}}" id="newsearchform" ></form>';
$('#newsearch').append(s);
s='<input type="hidden" name="search" value="true">';
$('#newsearchform').append(s);
s='<table id="newsearchtable"></table>';
$('#newsearchform').append(s);
s='<tr><td>Level in range:</td><td><input type="text" name="level_range" value="" placeholder="1..10"></td></tr>';
$('#newsearchtable').append(s);
s='<tr><td>R in range:</td><td><input type="text" name="ev_range" value="" placeholder="9.5..10"></td></tr>';
$('#newsearchtable').append(s);
s='<tr><td>Weight:</td><td><input type="text" name="weight" value="" placeholder="0"><span class="formexample">(leave blank for weight 0)</span></td></tr>';
$('#newsearchtable').append(s);
s='<tr><td>Character:</td><td><input type="text" name="character" value="" placeholder="0"><span class="formexample">(0 means trivial character, leave blank for all characters)</span></td></tr>';
$('#newsearchtable').append(s);
s='<tr><td colspan="2"><input type="submit" name="Submit" value="Search"></td> </tr>';
$('#newsearchtable').append(s);

 });

</script>
<style type="text/css">

a.paginate_button {
    padding:10px;
 } 
a.paginate_active {
    font-weight:bold;
    padding:10px;
 } 
</style>


{% if info.error is defined %}

<h1>There was an error in meeting your previous request. Please change parameters.</h1>

<div> 
<h2> Error message: </h2>% extends "homepage.html" %}

{{ info.error | safe }}
</div>
{% endif %}
<h1>{{info.title}}</h1>


{% if evs is defined %}
{% set table = evs.table %}
{% set nrows = table.nrows %}
{% set ncols = table.ncols %}
{% set data = table.data %}

<h2>Eigenvalues</h2>
<!--div id="searchresults" -->
<table class="ntdata pretty" id="eigenvalues">
  <colgroup>
    <col/> <col/><col/> 
    <col align="char" char="."/>
    <col/> <col/><col/> <col/> <col/> <col/>
  </colgroup>
  <thead>
    <tr>
    {% set sep="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" %}
    {% for knowl,title in table.colheads %}
      {% if title != "Atkin-Lehner" %}
         <th> {{KNOWL(knowl,title=title)}}</th>
      {% else %}
    <th style="width:200px">{{KNOWL(knowl,title=title)}}
   </th>
      {% endif %}
    {% endfor %}

    </tr>
  </thead>
  <tbody>
    {% set nnrows = 2000 %}
    {%if nrows < nnrows %}
     {% set nnrows = nrows %}
    {%endif%}
    {% for r in range(0,nnrows) %}
    {% if data[r] is defined %}
    <tr>
        <td>            
             {% if data[r].N is defined %} {{ data[r].N}}  {% endif %}
           </td>
           <td>            
             {% if data[r].k is defined %} {{ data[r].k}}  {% endif %}
           </td>
           <td>            
             {% if data[r].ch is defined %} {{ data[r].ch | safe }}  {% endif %}
           </td>
           <td>            
             {% if data[r].R is defined %} 
               {% if data[r].url is defined %} 
               <a href="{{ data[r].url}}">{{data[r].R}}</a>
               {% else %}
               {{data[r].R}}
               {% endif %}
            {% endif %}
           </td>
           <td>            
             {% if data[r].symmetry is defined %} {{ data[r].symmetry}}  {% endif %}
           </td>
           <td>            
             {% if data[r].err is defined %} {{ data[r].err}}  {% endif %}
           </td>
           <td>            
             {% if data[r].dim is defined %} {{ data[r].dim}}  {% endif %}
           </td>
           <td>            
             {% if data[r].numc is defined %} {{ data[r].numc}}  {% endif %}
           </td>
           <td>            
             {% if data[r].fricke is defined %} {{ data[r].fricke}}  {% endif %}
           </td>

           <td>            
             {% if data[r].cuspevs is defined %} {{ data[r].cuspevs}}  {% endif %}
           </td>
    </tr>
    {% endif %}
    {% endfor %}
   </tbody>
</table>
{# Make the new search floating  to get correct placement #}
{# What kind of metadata should be here?
<div id="knowl">
{{ KNOWL("metadata.knowl-tag") }}
</div>
#}
{% else %}
There are no eigenvalues in this database matching your search parameters.
{% endif %}
{% endblock content %}
